<!--
 * @Descripttion: 板件清单列表
 * @version:
 * @Author: lehaixia
 * @Date: 2022-10-28 15:07:39
 * @LastEditors: lehaixia
 * @LastEditTime: 2022-11-02 10:53:02
-->
<template>
  <div>
    <ComHeader title="板件清单列表" @get-height="handleHeadHeight" />
    <div class="plate">
      <div class="p-order">
        <div class="p-order-row"><div class="p-title">接单号</div> <div class="p-title">{{ parentObj.receiptNumber }}</div></div>
        <div class="p-order-row"><div class="p-title">柜号</div><div class="p-title">{{ parentObj.partNumber }}</div></div>
        <div class="p-order-row"><div class="p-title">整柜价格</div><div class="p-price">¥{{ parentObj.price }}</div></div>
      </div>

      <div v-if="plateList.length" class="p-pos">
        <div class="p-pos-head">
          <div class="p-pos-head-title">部件名称</div>
          <div class="p-pos-head-title">折扣价格</div>
        </div>
        <div class="p-pos-con">
          <div v-for="(p,i) in plateList" :key="i" class="p-order-row" @click="jumpToQuote(p)">
            <div class="p-title">{{ p.partName }}</div>
            <div class="p-title p-flex ">
              <span style="margin-right:4px">{{ p.discountPrice }}</span>
              <van-icon name="arrow" color="#A8B0C5" size="16" />
            </div>
          </div>
        </div>

      </div>
    </div>
  </div>
</template>
<script>
import arrowIcon from '@/assets/category/ic_arrow.png'
import { getOrderPriceList } from '@/apis/purOrder'

export default {
  name: 'OrderPlateDetail',
  components: { },
  props: {},
  data() {
    return {
      arrowIcon,
      headHeight: 50,
      plateList: [],
      parentObj: ''
    }
  },
  created() {
    const { id, orderId, partNumber, receiptNumber, price } = this.$route.query
    this.parentObj = { partNumber, receiptNumber, price }
    const data = {
      productId: id,
      crmId: orderId,
      partNumber
    }

    getOrderPriceList(data, { partNumber }).then(res => {
      if (res.success && res.data) {
        this.plateList = res.data || []
      }
    })
  },
  // 方法集合
  methods: {
    handleHeadHeight(h) {
      this.headHeight = h
    },
    jumpToQuote(row) {
      this.$router.push({
        path: '/purOrder/detail/quote'
      })
      sessionStorage.setItem('crm_quote', JSON.stringify(row))
    }
  }
}
</script>
<style lang='less' scoped>
.plate {
  padding: 20px 16px;
  .p-order {
    padding: 0 16px;
    background: #FFFFFF;
    border-radius: 12px;
    margin-bottom: 16px;
  }
  .p-order-row {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 52px;

    &::after {
      content: '';
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      height: 1px;
      background: #EFF2F7;
    }
    &:nth-last-of-type(1) {
      &::after {
        display: none;
      }
    }
  }

  .p-title {
    font-size: 14px;
    font-weight: 400;
    color: #3C4458;
    line-height: 20px;

    &:nth-of-type(1) {
      padding-left: 14px;
    }
  }
  .p-price {
    font-size: 14px;
    font-weight: 500;
    color: #F18548;
    line-height: 20px;
  }

  .p-flex {
    display: flex;
    align-items: center;
  }

  .p-pos {
    background: #FFFFFF;
    border-radius: 12px;
    margin-bottom: 16px;
    .p-pos-head {
      height: 44px;
      background: rgba(216,216,216,0.39);
      border-radius: 12px 12px 0px 0px;
      display: flex;
      align-items: center;
      margin-bottom: 16px;

      .p-pos-head-title {
        text-align: center;
        flex:1;
        position: relative;
        font-size: 14px;
        font-weight: 500;
        color: #3C4458;
        line-height: 44px;

        &:nth-of-type(1) {
          &::after{
            content: '';
            position: absolute;
            right: 0;
            top: 9px;
            width: 1px;
            height: 26px;
            background: rgba(151,151,151,0.2);
          }
        }
      }
    }
    .p-pos-con {
      padding: 0 16px;
    }
  }
}
</style>
